#!/bin/bash
REGISTRY="kmx.k2data.com.cn:5000"
SCRIPT_DIR=$(dirname $(readlink -e $0))
IMAGE_DIR=$SCRIPT_DIR/saved_images
mkdir -p $IMAGE_DIR
#export DOCKER_HOST=192.168.130.15:4243
cat $1 | while read line
do
        url=`echo $line | awk -F '/' '{print $1}' | awk -F ':' '{print $1}' | xargs`
        port=`echo $line | awk -F '/' '{print $1}' | awk -F ':' '{print $2}' | xargs`
        #new=`echo $line | awk -F '/' 'gsub("dev.k2data.com.cn:5001","kmx.k2data.com.cn:5000")' | xargs`
        old=`echo $line`
        new=`echo $line | awk -F '/' 'gsub("'$url':'$port'","'$REGISTRY'")' | xargs`
        echo  ${url} $port  $new
        set -x
#        docker pull $old
        docker tag $old $new
        docker push $new
        set +x
done
